using System;
using NUnit.Framework;

namespace ComponentTracer.Tests
{
    [TestFixture]
    public class ComponentTracer_event_Tests
    {
        [Test, Explicit]
        public void Der_Aufruf_eines_Events_wird_getraced() {
            var traceOutput = "";
            var service = new Service();
            service.Event += () => traceOutput += ": I was called";

            var tracedService = TracerProxy.Create<IService>(service, s => { traceOutput += s; });
            tracedService.FireEvent();

            Assert.That(traceOutput, Is.EqualTo("FireEvent([])Event([]): I was called"));

        }

        public interface IService
        {
            void FireEvent();

            event Action Event;
        }

        private class Service : IService
        {
            public event Action Event = delegate { };

            public void FireEvent() {
                Event();
            }
        }
    }
}